(function () {
  /* 创建一个定时器获取当前的时间 */
  const currentTime = document.querySelector('.currentTime');
  function getCurTime() {
    /* 获取当前的时间 */
    const curTime = new Date();
    /* 获取年月日时分秒 */
    const year = `${curTime.getFullYear()}`;
    const month = `${curTime.getMonth() + 1}`;
    const date = `${curTime.getDate()}`;
    const hours = `${curTime.getHours()}`;
    const minutes = `${curTime.getMinutes()}`;
    const seconds = `${curTime.getSeconds()}`;
    const resTime = `${year.padStart(2, 0)}-${month.padStart(2, 0)}-${date.padStart(2, 0)} ${hours.padStart(2, 0)}:${minutes.padStart(2, 0)}:${seconds.padStart(2, 0)}`;
    setTimeout(getCurTime, 100);
    currentTime.innerHTML = `当前时间 : ${resTime}`;
  }
  getCurTime();
}());
